<!DOCTYPE html>
<html lang="en">
<head>
    <include file="Public:header2" />
    <script type="text/javascript" src="__PUBLIC__/layer/layer.js"></script>
    <script type="text/javascript" src="__PUBLIC__/Home/js/jquery.cookies.2.2.0.js"></script>
</head>
<link rel="stylesheet" href="__PUBLIC__/intel/css/intlTelInput.css">
<script src="__PUBLIC__/intel/js/intlTelInput.js"></script>
<style type="text/css">
.intl-tel-input.separate-dial-code .selected-dial-code{color:#fff;font-size: 0.8rem;}
</style>
<body class="blackbg">
    <div id="container" class="logbg">
        <div class="log_title">
            <span class="back"><a href="javascript:history.go(-1)"></a></span>
            {:L('找回密码')}
        </div>
        <div class="logbot">
            <form>

                <!-- 用户名 -->
                <!-- <input type="text" placeholder="用户名" class="logipt"  id="username" name="username" > -->

                <!-- 手机号 -->
                <input type="text" placeholder="{:L('mobile')}" class="logipt" id="mobile" name="mobile" >

                <!-- 图形验证码 -->
                <div class="yzmbox">
                    <input type="text" placeholder="{:L('captcha')}" class="logipt yzmipt"  id="verify" name="code" >
                    <img id="codeImg" src="{:U('Verify/code')}" width="145" height="42" onclick="this.src=this.src+'?t='+Math.random()" style=" cursor: pointer;" title="{:L('换一张')}">
                </div>

                <!-- 短信验证码 -->
                <div class="yzmbox">
                    <input type="text" placeholder="{:L('mobile_captcha')}" class="logipt yzmipt" id="mobile_verify" name="code">
                    <input type="button" value="{:L('get_captcha')}" class="phonebut" onclick="SendCode()"  id="regBtn" style="background:#ff9900;color:#fff;">
                </div>

                <!-- 密保问题 -->


                <select class="logipt" id="mibao_question">
                    <option value="">{:L('请选择密保问题')}</option>
                    <option value="{:L('你父亲的姓名')}">{:L('你父亲的姓名')}</option>
                    <option value="{:L('你母亲的姓名')}">{:L('你母亲的姓名')}</option>
                    <option value="{:L('你爱人的姓名')}">{:L('你爱人的姓名')}</option>
                    <option value="{:L('你的出生日期')}">{:L('你的出生日期')}</option>
                    <option value="{:L('你父亲的出生日期')}">{:L('你父亲的出生日期')}</option>
                    <option value="{:L('你母亲的出生日期')}">{:L('你母亲的出生日期')}</option>
                    <option value="{:L('你爱人的出生日期')}">{:L('你爱人的出生日期')}</option>
                </select>

                <!-- 问题答案 -->
                <input type="text" placeholder="{:L('answers_to_questions')}" class="logipt" id="mibao_answer">
              <!--   <div class="yzmbox" style="color:rgba(255,255,255,.4);font-size:14px;line-height:20px;">

                    {:L('forget_encrypted_problem_tips')} {:L('support_email')}


                </div> -->
                <!-- 新登录密码 -->
                <input type="password" placeholder="{:L('登录密码')}" class="logipt" id="password" name="password" >

                <!-- 确认登录密码 -->
                <input type="password" placeholder="{:L('重复密码')}" class="logipt"  id="repassword" name="repassword" >
                <input type="button" class="logbut" value="{:L('重置密码')}" onclick="Update();">
            </form>
        </div>
    </div>
<script type="text/javascript">
   $("#mobile").intlTelInput({
      allowDropdown: true,
      // autoHideDialCode: true,
      // autoPlaceholder: "off",
      dropdownContainer: "body",
      // excludeCountries: ["us"],
      // formatOnDisplay: true,
      // geoIpLookup: function(callback) {
      //   $.get("http://ipinfo.io", function() {}, "jsonp").always(function(resp) {
      //     var countryCode = (resp && resp.country) ? resp.country : "";
      //     callback(countryCode);
      //   });
      // },
      initialCountry: "cn",
      nationalMode: true,
      // onlyCountries: ['us', 'fr', 'ca', 'jp','kr','de','cn','ru'],
      // placeholderNumberType: "MOBILE",
      // preferredCountries: ['cn', 'jp'],
      separateDialCode: true,
      utilsScript: "/Public/intel/js/utils.js"
    });

</script>
<script>

   function SendCode(){
        var mobile=$("#mobile").val();
        var verify=$("#verify").val();
                var intlNumber = $("#mobile").intlTelInput("getSelectedCountryData");//获取国家代码
       var intnum =  intlNumber['dialCode'];//获取国家代码
      var isValid = $("#mobile").intlTelInput("isValidNumber");//验证手机号码是否正确
        if(mobile==""||mobile==null){
            layer.tips('{:L('请输入手机号码')}','#mobile',{tips:3});
            return false;
        }
        if (isValid!=true) {
        layer.tips('{$Think.lang.手机号码不正确}', '#mobile', { tips: 3 });
        return false;
    }
        if(verify==""||verify==null){
            layer.tips('{:L('请输入图形验证码')}','#verify',{tips:3});
            return false;
        }
		layer.load(0, {shade: [0.5,'#8F8F8F']});
        $.post("{:U('Verify/findpwd')}",{mobile:mobile,verify:verify,intnum:intnum},function(data){
			layer.closeAll();
            if(data.status==1){
                $('#regBtn').attr("disabled","disabled");
                layer.msg(data.info,{icon:1});
                var obj=$('#regBtn');
                var wait=120;
                var interval=setInterval(function(){
                    obj.css('backgroundColor','#999');
                    obj.val('（'+wait+'）秒后再次发送');
                    wait--;
                    if(wait<0){
                        $('#regBtn').removeAttr("disabled");
                        clearInterval(interval);
                        obj.val('获取验证码');
                        obj.css('backgroundColor','#ff9900');
                    }
                    ;
                },1000);
            }else{
                $('#regBtn').removeAttr("disabled");
                layer.msg(data.info,{icon:2});
            }
        },"json");
    }



    function Update(){
        var mobile=$("#mobile").val();
        var mobile_verify=$("#mobile_verify").val();
        var verify=$("#verify").val();
        var password=$("#password").val();
        var repassword=$("#repassword").val();
        var mibao_question=$("#mibao_question").val();
        var mibao_answer=$("#mibao_answer").val();
        if(mobile==""||mobile==null){
            layer.tips('{:L('请输入手机号码')}','#mobile',{tips:3});
            return false;
        }
        if(mobile_verify==""||mobile_verify==null){
            layer.tips('{:L('请输入手机验证码')}','#mobile_verify',{tips:3});
            return false;
        }
        if(verify==""||verify==null){
            layer.tips('{:L('请输入图形验证码')}','#verify',{tips:3});
            return false;
        }
        if(mibao_question==""||mibao_question==null){
            layer.tips('{:L('请选择密保问题')}','#mibao_question',{tips:3});
            return false;
        }
        if(mibao_answer==""||mibao_answer==null){
            layer.tips('{:L('请输入密保问题答案')}','#mibao_answer',{tips:3});
            return false;
        }
        if(password==""||password==null){
            layer.tips('{:L('请输入新登录密码')}','#password',{tips:3});
            return false;
        }
        if(repassword==""||repassword==null){
            layer.tips('{:L('请输入确认登录密码')}','#repassword',{tips:3});
            return false;
        }
        if(password!=repassword){
            layer.tips('{:L('两次输入的密码不一致！')}','#repassword',{tips:3});
            return false;
        }
        $.post("{:U('Login/findpwd')}",{mobile:mobile,mobile_verify:mobile_verify,verify:verify,password:password,repassword:repassword,mibao_question:mibao_question,mibao_answer:mibao_answer},function(data){
            if(data.status==1){
                layer.msg(data.info,{icon:1});
                window.setTimeout("window.location='{:U('Login/index')}'",1000);
            }else{
                layer.msg(data.info,{icon:2});
            }
        },"json");
    }
</script>
</body>
</html>